From 44178c0541ca46f53c41953e32529eabc1931a2b Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 24 Feb 2016 14:21:10 -0800 Subject: [PATCH] gadget: add API to get various area boxes Compared to the function returning the allocation, these will return the box in gadget coordinates. --- gtk/gtkcssgadget.c | 51 +++++++++++++++++++++++++++++++++++++++ gtk/gtkcssgadgetprivate.h | 6 +++++ 2 files changed, 57 insertions(+) diff --git a/gtk/gtkcssgadget.c b/gtk/gtkcssgadget.c index af7afb5998..1c68a7afce 100644 --- a/gtk/gtkcssgadget.c +++ b/gtk/gtkcssgadget.c @@ -956,6 +956,57 @@ gtk_css_gadget_queue_draw (GtkCssGadget *gadget) gtk_widget_queue_draw (gtk_css_gadget_get_owner (gadget)); } +/** + * gtk_css_gadget_get_margin_box: + * @gadget: a #GtkCssGadget + * @box: (out): Return location for gadget's the margin box + * + * Returns the margin box of the gadget. The box coordinates are relative to + * the gadget origin. Compare with gtk_css_gadget_get_margin_allocation(), + * which returns the margin box in the widget allocation coordinates. + */ +void +gtk_css_gadget_get_margin_box (GtkCssGadget *gadget, + GtkAllocation *box) +{ + gtk_css_gadget_get_margin_allocation (gadget, box, NULL); + shift_allocation (gadget, box); +} + +/** + * gtk_css_gadget_get_border_box: + * @gadget: a #GtkCssGadget + * @box: (out): Return location for gadget's the border box + * + * Returns the border box of the gadget. The box coordinates are relative to + * the gadget origin. Compare with gtk_css_gadget_get_border_allocation(), + * which returns the border box in the widget allocation coordinates. + */ +void +gtk_css_gadget_get_border_box (GtkCssGadget *gadget, + GtkAllocation *box) +{ + gtk_css_gadget_get_border_allocation (gadget, box, NULL); + shift_allocation (gadget, box); +} + +/** + * gtk_css_gadget_get_content_box: + * @gadget: a #GtkCssGadget + * @box: (out): Return location for gadget's the content box + * + * Returns the content box of the gadget. The box coordinates are relative to + * the gadget origin. Compare with gtk_css_gadget_get_content_allocation(), + * which returns the content box in the widget allocation coordinates. + */ +void +gtk_css_gadget_get_content_box (GtkCssGadget *gadget, + GtkAllocation *box) +{ + gtk_css_gadget_get_content_allocation (gadget, box, NULL); + shift_allocation (gadget, box); +} + void gtk_css_gadget_get_margin_allocation (GtkCssGadget *gadget, GtkAllocation *allocation, diff --git a/gtk/gtkcssgadgetprivate.h b/gtk/gtkcssgadgetprivate.h index 657813583c..fa3c409028 100644 --- a/gtk/gtkcssgadgetprivate.h +++ b/gtk/gtkcssgadgetprivate.h @@ -93,6 +93,12 @@ gboolean gtk_css_gadget_border_box_contains_point (GtkCssGadget gboolean gtk_css_gadget_content_box_contains_point (GtkCssGadget *gadget, int x, int y); +void gtk_css_gadget_get_margin_box (GtkCssGadget *gadget, + GtkAllocation *box); +void gtk_css_gadget_get_border_box (GtkCssGadget *gadget, + GtkAllocation *box); +void gtk_css_gadget_get_content_box (GtkCssGadget *gadget, + GtkAllocation *box); void gtk_css_gadget_add_class (GtkCssGadget *gadget, const char *name); -- 2.30.2